<template>
  <Dialog :title="dialogTitle" v-model="dialogVisible">
    <el-form
      ref="formRef"
      :model="formData"
      :rules="formRules"
      label-width="100px"
      v-loading="formLoading"
    >
      <el-form-item :label="t('ustcStudentInfoUniversity.fields.accountId')" prop="accountId">
        <el-input
          v-model="formData.accountId"
          :placeholder="
            t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.accountId')
          "
        />
      </el-form-item>
      <el-form-item :label="t('ustcStudentInfoUniversity.fields.inschoolFlag')" prop="inschoolFlag">
        <el-input
          v-model="formData.inschoolFlag"
          :placeholder="
            t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.inschoolFlag')
          "
        />
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.studentStatus')"
        prop="studentStatus"
      >
        <el-radio-group v-model="formData.studentStatus">
          <el-radio value="1">请选择字典生成</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.studentStatusChange')"
        prop="studentStatusChange"
      >
        <el-input
          v-model="formData.studentStatusChange"
          :placeholder="
            t('common.inputTextPlaceholder') +
            t('ustcStudentInfoUniversity.fields.studentStatusChange')
          "
        />
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.admissionSeason')"
        prop="admissionSeason"
      >
        <el-input
          v-model="formData.admissionSeason"
          :placeholder="
            t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.admissionSeason')
          "
        />
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.admissionTime')"
        prop="admissionTime"
      >
        <el-date-picker
          v-model="formData.admissionTime"
          type="date"
          value-format="x"
          :placeholder="
            t('common.selectTextPlaceholder') + t('ustcStudentInfoUniversity.fields.admissionTime')
          "
        />
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.admissionType')"
        prop="admissionType"
      >
        <el-select
          v-model="formData.admissionType"
          :placeholder="
            t('common.selectTextPlaceholder') + t('ustcStudentInfoUniversity.fields.admissionType')
          "
        >
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item :label="t('ustcStudentInfoUniversity.fields.studentType')" prop="studentType">
        <el-select
          v-model="formData.studentType"
          :placeholder="
            t('common.selectTextPlaceholder') + t('ustcStudentInfoUniversity.fields.studentType')
          "
        >
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item :label="t('ustcStudentInfoUniversity.fields.eduDuration')" prop="eduDuration">
        <el-input
          v-model="formData.eduDuration"
          :placeholder="
            t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.eduDuration')
          "
        />
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.trainingLevel')"
        prop="trainingLevel"
      >
        <el-input
          v-model="formData.trainingLevel"
          :placeholder="
            t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.trainingLevel')
          "
        />
      </el-form-item>
      <el-form-item :label="t('ustcStudentInfoUniversity.fields.grade')" prop="grade">
        <el-input
          v-model="formData.grade"
          :placeholder="
            t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.grade')
          "
        />
      </el-form-item>
      <el-form-item :label="t('ustcStudentInfoUniversity.fields.faculty')" prop="faculty">
        <el-input
          v-model="formData.faculty"
          :placeholder="
            t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.faculty')
          "
        />
      </el-form-item>
      <el-form-item :label="t('ustcStudentInfoUniversity.fields.major')" prop="major">
        <el-input
          v-model="formData.major"
          :placeholder="
            t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.major')
          "
        />
      </el-form-item>
      <el-form-item :label="t('ustcStudentInfoUniversity.fields.category')" prop="category">
        <el-input
          v-model="formData.category"
          :placeholder="
            t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.category')
          "
        />
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.firstLevelSubject')"
        prop="firstLevelSubject"
      >
        <el-input
          v-model="formData.firstLevelSubject"
          :placeholder="
            t('common.inputTextPlaceholder') +
            t('ustcStudentInfoUniversity.fields.firstLevelSubject')
          "
        />
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.professionalDirection')"
        prop="professionalDirection"
      >
        <el-input
          v-model="formData.professionalDirection"
          :placeholder="
            t('common.inputTextPlaceholder') +
            t('ustcStudentInfoUniversity.fields.professionalDirection')
          "
        />
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.trainingMethod')"
        prop="trainingMethod"
      >
        <el-input
          v-model="formData.trainingMethod"
          :placeholder="
            t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.trainingMethod')
          "
        />
      </el-form-item>
      <el-form-item :label="t('ustcStudentInfoUniversity.fields.learnMethod')" prop="learnMethod">
        <el-input
          v-model="formData.learnMethod"
          :placeholder="
            t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.learnMethod')
          "
        />
      </el-form-item>
      <el-form-item :label="t('ustcStudentInfoUniversity.fields.specialPlan')" prop="specialPlan">
        <el-input
          v-model="formData.specialPlan"
          :placeholder="
            t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.specialPlan')
          "
        />
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.elecAcademicRegNote')"
        prop="elecAcademicRegNote"
      >
        <el-input
          v-model="formData.elecAcademicRegNote"
          :placeholder="
            t('common.inputTextPlaceholder') +
            t('ustcStudentInfoUniversity.fields.elecAcademicRegNote')
          "
        />
      </el-form-item>
      <el-form-item :label="t('ustcStudentInfoUniversity.fields.classroom')" prop="classroom">
        <el-input
          v-model="formData.classroom"
          :placeholder="
            t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.classroom')
          "
        />
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.primaryMentor')"
        prop="primaryMentor"
      >
        <el-input
          v-model="formData.primaryMentor"
          :placeholder="
            t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.primaryMentor')
          "
        />
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.secondaryMentor')"
        prop="secondaryMentor"
      >
        <el-input
          v-model="formData.secondaryMentor"
          :placeholder="
            t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.secondaryMentor')
          "
        />
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.residenceCampus')"
        prop="residenceCampus"
      >
        <el-input
          v-model="formData.residenceCampus"
          :placeholder="
            t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.residenceCampus')
          "
        />
      </el-form-item>
      <el-form-item :label="t('ustcStudentInfoUniversity.fields.dormAddress')" prop="dormAddress">
        <el-input
          v-model="formData.dormAddress"
          :placeholder="
            t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.dormAddress')
          "
        />
      </el-form-item>
      <el-form-item :label="t('ustcStudentInfoUniversity.fields.basicPeriod')" prop="basicPeriod">
        <el-date-picker
          v-model="formData.basicPeriod"
          type="date"
          value-format="x"
          :placeholder="
            t('common.selectTextPlaceholder') + t('ustcStudentInfoUniversity.fields.basicPeriod')
          "
        />
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.longestPeriod')"
        prop="longestPeriod"
      >
        <el-date-picker
          v-model="formData.longestPeriod"
          type="date"
          value-format="x"
          :placeholder="
            t('common.selectTextPlaceholder') + t('ustcStudentInfoUniversity.fields.longestPeriod')
          "
        />
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.registerStatus')"
        prop="registerStatus"
      >
        <el-radio-group v-model="formData.registerStatus">
          <el-radio value="1">请选择字典生成</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.fundingPeriod')"
        prop="fundingPeriod"
      >
        <el-date-picker
          v-model="formData.fundingPeriod"
          type="date"
          value-format="x"
          :placeholder="
            t('common.selectTextPlaceholder') + t('ustcStudentInfoUniversity.fields.fundingPeriod')
          "
        />
      </el-form-item>
      <el-form-item :label="t('ustcStudentInfoUniversity.fields.defenseDate')" prop="defenseDate">
        <el-date-picker
          v-model="formData.defenseDate"
          type="date"
          value-format="x"
          :placeholder="
            t('common.selectTextPlaceholder') + t('ustcStudentInfoUniversity.fields.defenseDate')
          "
        />
      </el-form-item>
      <el-form-item :label="t('ustcStudentInfoUniversity.fields.leaveDate')" prop="leaveDate">
        <el-date-picker
          v-model="formData.leaveDate"
          type="date"
          value-format="x"
          :placeholder="
            t('common.selectTextPlaceholder') + t('ustcStudentInfoUniversity.fields.leaveDate')
          "
        />
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.graduationConclusion')"
        prop="graduationConclusion"
      >
        <el-input
          v-model="formData.graduationConclusion"
          :placeholder="
            t('common.inputTextPlaceholder') +
            t('ustcStudentInfoUniversity.fields.graduationConclusion')
          "
        />
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.graduationDate')"
        prop="graduationDate"
      >
        <el-date-picker
          v-model="formData.graduationDate"
          type="date"
          value-format="x"
          :placeholder="
            t('common.selectTextPlaceholder') + t('ustcStudentInfoUniversity.fields.graduationDate')
          "
        />
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.graduationNumber')"
        prop="graduationNumber"
      >
        <el-input
          v-model="formData.graduationNumber"
          :placeholder="
            t('common.inputTextPlaceholder') +
            t('ustcStudentInfoUniversity.fields.graduationNumber')
          "
        />
      </el-form-item>
      <el-form-item :label="t('ustcStudentInfoUniversity.fields.degreeType')" prop="degreeType">
        <el-select
          v-model="formData.degreeType"
          :placeholder="
            t('common.selectTextPlaceholder') + t('ustcStudentInfoUniversity.fields.degreeType')
          "
        >
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item :label="t('ustcStudentInfoUniversity.fields.degree')" prop="degree">
        <el-input
          v-model="formData.degree"
          :placeholder="
            t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.degree')
          "
        />
      </el-form-item>
      <el-form-item :label="t('ustcStudentInfoUniversity.fields.degreeDate')" prop="degreeDate">
        <el-date-picker
          v-model="formData.degreeDate"
          type="date"
          value-format="x"
          :placeholder="
            t('common.selectTextPlaceholder') + t('ustcStudentInfoUniversity.fields.degreeDate')
          "
        />
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.phdInResearch')"
        prop="phdInResearch"
      >
        <el-radio-group v-model="formData.phdInResearch">
          <el-radio value="1">请选择字典生成</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item :label="t('ustcStudentInfoUniversity.fields.transferYear')" prop="transferYear">
        <el-input
          v-model="formData.transferYear"
          :placeholder="
            t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.transferYear')
          "
        />
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.destinationType')"
        prop="destinationType"
      >
        <el-select
          v-model="formData.destinationType"
          :placeholder="
            t('common.selectTextPlaceholder') +
            t('ustcStudentInfoUniversity.fields.destinationType')
          "
        >
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.destinationUnit')"
        prop="destinationUnit"
      >
        <el-input
          v-model="formData.destinationUnit"
          :placeholder="
            t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.destinationUnit')
          "
        />
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.archiveAddress')"
        prop="archiveAddress"
      >
        <el-input
          v-model="formData.archiveAddress"
          :placeholder="
            t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.archiveAddress')
          "
        />
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.archiveContact')"
        prop="archiveContact"
      >
        <el-input
          v-model="formData.archiveContact"
          :placeholder="
            t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.archiveContact')
          "
        />
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.archiveTelephone')"
        prop="archiveTelephone"
      >
        <el-input
          v-model="formData.archiveTelephone"
          :placeholder="
            t('common.inputTextPlaceholder') +
            t('ustcStudentInfoUniversity.fields.archiveTelephone')
          "
        />
      </el-form-item>
      <el-form-item :label="t('ustcStudentInfoUniversity.fields.confirmLeave')" prop="confirmLeave">
        <el-radio-group v-model="formData.confirmLeave">
          <el-radio value="1">请选择字典生成</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item :label="t('ustcStudentInfoUniversity.fields.remark')" prop="remark">
        <el-input
          v-model="formData.remark"
          :placeholder="
            t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.remark')
          "
        />
      </el-form-item>
    </el-form>
    <template #footer>
      <el-button @click="submitForm" type="primary" :disabled="formLoading"
        >{{ t('common.ok') }}
      </el-button>
      <el-button @click="dialogVisible = false">{{ t('common.cancel') }}</el-button>
    </template>
  </Dialog>
</template>
<script setup lang="ts">
import {
  UstcStudentInfoUniversityApi,
  UstcStudentInfoUniversityVO
} from '@/api/core/ustcstudentinfouniversity'
import { FormRules } from 'element-plus'

/** 学生在校信息 表单 */
defineOptions({ name: 'UstcStudentInfoUniversityForm' })

const { t } = useI18n() // 国际化
const message = useMessage() // 消息弹窗

const dialogVisible = ref(false) // 弹窗的是否展示
const dialogTitle = ref('') // 弹窗的标题
const formLoading = ref(false) // 表单的加载中：1）修改时的数据加载；2）提交的按钮禁用
const formType = ref('') // 表单的类型：create - 新增；update - 修改
const formData = ref({
  id: undefined,
  accountId: undefined,
  inschoolFlag: undefined,
  studentStatus: undefined,
  studentStatusChange: undefined,
  admissionSeason: undefined,
  admissionTime: undefined,
  admissionType: undefined,
  studentType: undefined,
  eduDuration: undefined,
  trainingLevel: undefined,
  grade: undefined,
  faculty: undefined,
  major: undefined,
  category: undefined,
  firstLevelSubject: undefined,
  professionalDirection: undefined,
  trainingMethod: undefined,
  learnMethod: undefined,
  specialPlan: undefined,
  elecAcademicRegNote: undefined,
  classroom: undefined,
  primaryMentor: undefined,
  secondaryMentor: undefined,
  residenceCampus: undefined,
  dormAddress: undefined,
  basicPeriod: undefined,
  longestPeriod: undefined,
  registerStatus: undefined,
  fundingPeriod: undefined,
  defenseDate: undefined,
  leaveDate: undefined,
  graduationConclusion: undefined,
  graduationDate: undefined,
  graduationNumber: undefined,
  degreeType: undefined,
  degree: undefined,
  degreeDate: undefined,
  phdInResearch: undefined,
  transferYear: undefined,
  destinationType: undefined,
  destinationUnit: undefined,
  archiveAddress: undefined,
  archiveContact: undefined,
  archiveTelephone: undefined,
  confirmLeave: undefined,
  remark: undefined
})
const formRules = reactive<FormRules>({
  id: [
    {
      required: true,
      message: t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.id'),
      trigger: 'blur'
    }
  ],
  accountId: [
    {
      required: true,
      message: t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.accountId'),
      trigger: 'blur'
    }
  ],
  inschoolFlag: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.inschoolFlag'),
      trigger: 'blur'
    }
  ],
  studentStatus: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.studentStatus'),
      trigger: 'blur'
    }
  ],
  studentStatusChange: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') +
        t('ustcStudentInfoUniversity.fields.studentStatusChange'),
      trigger: 'blur'
    }
  ],
  admissionSeason: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.admissionSeason'),
      trigger: 'blur'
    }
  ],
  admissionTime: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.admissionTime'),
      trigger: 'blur'
    }
  ],
  admissionType: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.admissionType'),
      trigger: 'change'
    }
  ],
  studentType: [
    {
      required: true,
      message: t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.studentType'),
      trigger: 'change'
    }
  ],
  eduDuration: [
    {
      required: true,
      message: t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.eduDuration'),
      trigger: 'blur'
    }
  ],
  trainingLevel: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.trainingLevel'),
      trigger: 'blur'
    }
  ],
  grade: [
    {
      required: true,
      message: t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.grade'),
      trigger: 'blur'
    }
  ],
  faculty: [
    {
      required: true,
      message: t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.faculty'),
      trigger: 'blur'
    }
  ],
  major: [
    {
      required: true,
      message: t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.major'),
      trigger: 'blur'
    }
  ],
  category: [
    {
      required: true,
      message: t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.category'),
      trigger: 'blur'
    }
  ],
  firstLevelSubject: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.firstLevelSubject'),
      trigger: 'blur'
    }
  ],
  professionalDirection: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') +
        t('ustcStudentInfoUniversity.fields.professionalDirection'),
      trigger: 'blur'
    }
  ],
  trainingMethod: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.trainingMethod'),
      trigger: 'blur'
    }
  ],
  learnMethod: [
    {
      required: true,
      message: t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.learnMethod'),
      trigger: 'blur'
    }
  ],
  specialPlan: [
    {
      required: true,
      message: t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.specialPlan'),
      trigger: 'blur'
    }
  ],
  elecAcademicRegNote: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') +
        t('ustcStudentInfoUniversity.fields.elecAcademicRegNote'),
      trigger: 'blur'
    }
  ],
  classroom: [
    {
      required: true,
      message: t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.classroom'),
      trigger: 'blur'
    }
  ],
  primaryMentor: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.primaryMentor'),
      trigger: 'blur'
    }
  ],
  secondaryMentor: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.secondaryMentor'),
      trigger: 'blur'
    }
  ],
  residenceCampus: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.residenceCampus'),
      trigger: 'blur'
    }
  ],
  dormAddress: [
    {
      required: true,
      message: t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.dormAddress'),
      trigger: 'blur'
    }
  ],
  basicPeriod: [
    {
      required: true,
      message: t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.basicPeriod'),
      trigger: 'blur'
    }
  ],
  longestPeriod: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.longestPeriod'),
      trigger: 'blur'
    }
  ],
  registerStatus: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.registerStatus'),
      trigger: 'blur'
    }
  ],
  fundingPeriod: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.fundingPeriod'),
      trigger: 'blur'
    }
  ],
  defenseDate: [
    {
      required: true,
      message: t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.defenseDate'),
      trigger: 'blur'
    }
  ],
  leaveDate: [
    {
      required: true,
      message: t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.leaveDate'),
      trigger: 'blur'
    }
  ],
  graduationConclusion: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') +
        t('ustcStudentInfoUniversity.fields.graduationConclusion'),
      trigger: 'blur'
    }
  ],
  graduationDate: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.graduationDate'),
      trigger: 'blur'
    }
  ],
  graduationNumber: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.graduationNumber'),
      trigger: 'blur'
    }
  ],
  degreeType: [
    {
      required: true,
      message: t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.degreeType'),
      trigger: 'change'
    }
  ],
  degree: [
    {
      required: true,
      message: t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.degree'),
      trigger: 'blur'
    }
  ],
  degreeDate: [
    {
      required: true,
      message: t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.degreeDate'),
      trigger: 'blur'
    }
  ],
  phdInResearch: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.phdInResearch'),
      trigger: 'blur'
    }
  ],
  transferYear: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.transferYear'),
      trigger: 'blur'
    }
  ],
  destinationType: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.destinationType'),
      trigger: 'change'
    }
  ],
  destinationUnit: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.destinationUnit'),
      trigger: 'blur'
    }
  ],
  archiveAddress: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.archiveAddress'),
      trigger: 'blur'
    }
  ],
  archiveContact: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.archiveContact'),
      trigger: 'blur'
    }
  ],
  archiveTelephone: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.archiveTelephone'),
      trigger: 'blur'
    }
  ],
  confirmLeave: [
    {
      required: true,
      message:
        t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.confirmLeave'),
      trigger: 'blur'
    }
  ],
  remark: [
    {
      required: true,
      message: t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.remark'),
      trigger: 'blur'
    }
  ],
  creator: [
    {
      required: true,
      message: t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.creator'),
      trigger: 'blur'
    }
  ],
  createTime: [
    {
      required: true,
      message: t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.createTime'),
      trigger: 'blur'
    }
  ],
  updater: [
    {
      required: true,
      message: t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.updater'),
      trigger: 'blur'
    }
  ],
  updateTime: [
    {
      required: true,
      message: t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.updateTime'),
      trigger: 'blur'
    }
  ],
  deleted: [
    {
      required: true,
      message: t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.deleted'),
      trigger: 'blur'
    }
  ],
  tenantId: [
    {
      required: true,
      message: t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.tenantId'),
      trigger: 'blur'
    }
  ]
})
const formRef = ref() // 表单 Ref

/** 打开弹窗 */
const open = async (type: string, id?: number) => {
  dialogVisible.value = true
  dialogTitle.value = t('action.' + type)
  formType.value = type
  resetForm()
  // 修改时，设置数据
  if (id) {
    formLoading.value = true
    try {
      formData.value = await UstcStudentInfoUniversityApi.getStudentInfoUniversity(id)
    } finally {
      formLoading.value = false
    }
  }
}
defineExpose({ open }) // 提供 open 方法，用于打开弹窗

/** 提交表单 */
const emit = defineEmits(['success']) // 定义 success 事件，用于操作成功后的回调
const submitForm = async () => {
  // 校验表单
  await formRef.value.validate()
  // 提交请求
  formLoading.value = true
  try {
    const data = formData.value as unknown as UstcStudentInfoUniversityVO
    if (formType.value === 'create') {
      await UstcStudentInfoUniversityApi.createStudentInfoUniversity(data)
      message.success(t('common.createSuccess'))
    } else {
      await UstcStudentInfoUniversityApi.updateStudentInfoUniversity(data)
      message.success(t('common.updateSuccess'))
    }
    dialogVisible.value = false
    // 发送操作成功的事件
    emit('success')
  } finally {
    formLoading.value = false
  }
}

/** 重置表单 */
const resetForm = () => {
  formData.value = {
    id: undefined,
    accountId: undefined,
    inschoolFlag: undefined,
    studentStatus: undefined,
    studentStatusChange: undefined,
    admissionSeason: undefined,
    admissionTime: undefined,
    admissionType: undefined,
    studentType: undefined,
    eduDuration: undefined,
    trainingLevel: undefined,
    grade: undefined,
    faculty: undefined,
    major: undefined,
    category: undefined,
    firstLevelSubject: undefined,
    professionalDirection: undefined,
    trainingMethod: undefined,
    learnMethod: undefined,
    specialPlan: undefined,
    elecAcademicRegNote: undefined,
    classroom: undefined,
    primaryMentor: undefined,
    secondaryMentor: undefined,
    residenceCampus: undefined,
    dormAddress: undefined,
    basicPeriod: undefined,
    longestPeriod: undefined,
    registerStatus: undefined,
    fundingPeriod: undefined,
    defenseDate: undefined,
    leaveDate: undefined,
    graduationConclusion: undefined,
    graduationDate: undefined,
    graduationNumber: undefined,
    degreeType: undefined,
    degree: undefined,
    degreeDate: undefined,
    phdInResearch: undefined,
    transferYear: undefined,
    destinationType: undefined,
    destinationUnit: undefined,
    archiveAddress: undefined,
    archiveContact: undefined,
    archiveTelephone: undefined,
    confirmLeave: undefined,
    remark: undefined
  }
  formRef.value?.resetFields()
}
</script>
